/* eslint valid-jsdoc: "off" */
const Path = require('path');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});
  const { baseDir } = appInfo;

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1717724104831_2082';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // 通义千问
  config.bailianAI = {
    apiKey: process.env.BAILIAN_API_KEY, // 替换为你的API密钥
    apiUrl:
      'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation', // 替换为实际API URL
  };
  // 配置: xtpl模板渲染
  config.view = {
    defaultViewEngine: 'xtpl',
    mapping: {
      '.html': 'xtpl',
    },
  };
  // 静态资源配置
  config.static = {
    prefix: '/public',
    dir: Path.join(baseDir, 'app/public'),
    gzip: true,
  };

  // 安全配置
  config.security = {
    csrf: {
      enable: false,
    },
  };

  return {
    ...config,
    ...userConfig,
  };
};
